Skip to content

Add referer header for Duck Player - #6407

Merged
CrisBarreiro merged 5 commits into
developfrom
feature/cris/duckplayer/add-referer-header
Aug 1, 2025
Merged

CrisBarreiro merged 5 commits into
developfrom
feature/cris/duckplayer/add-referer-header

Conversation

@CrisBarreiro

@CrisBarreiro CrisBarreiro commented Jul 16, 2025

Copy link
Copy Markdown
Collaborator

Task/Issue URL: https://app.asana.com/1/137249556945/task/1210811808963690?focus=true

Description

Set referer header to local assets directory in compliance with new TOS

Steps to test this PR

Feature 1

  • Set up Charles Proxy
    • Disable macOS proxy under Charles toolbar > Proxy
    • Enable SSL proxying and include location *:* under Charles toolbar > Proxy > SSL Proxying settings
    • Check IP address under Charles toolbar > Help > Local IP addresses. Check port under Charles toolbar > Proxy settings
  • Set up proxy for WiFi connection on your phone by setting IP address and port from previous step
  • Open the app and load http://charlesproxy.com/getssl
  • Download the certificate and install as CA certificate
  • Load a video on Duck Player
  • Using Charles proxy, check that requests to https://www.youtube-nocookie.com/embed/... have referer header set to http://android.mobile.duckduckgo.com

UI changes

n/a

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CrisBarreiro
CrisBarreiro force-pushed the feature/cris/duckplayer/add-referer-header branch from 14e08f2 to c7ee8da Compare July 16, 2025 15:29
@CrisBarreiro CrisBarreiro changed the title Add referer header Add referer header for Duck Player Jul 16, 2025

@marcosholgado marcosholgado left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to test this but was not able to. Couldn't consistently see embeds calls, with Charles they are all encrypted since we don't own the domain and with chrome inspect it only gave me the basic headers.

Would be great to have more detailed testing steps and also change from draft to ready to review once the TODO is done.

@CrisBarreiro
CrisBarreiro force-pushed the feature/cris/duckplayer/add-referer-header branch 2 times, most recently from 47ca5de to c2ffb28 Compare July 30, 2025 15:15
@CrisBarreiro
CrisBarreiro force-pushed the feature/cris/duckplayer/add-referer-header branch from c2ffb28 to 6222e57 Compare July 30, 2025 15:19
@CrisBarreiro
CrisBarreiro marked this pull request as ready for review July 31, 2025 08:44
return processSimulatedYouTubeNoCookieUri(url, webView)
} else if (duckPlayerFeature.addCustomEmbedReferer().isEnabled() && isYouTubeNoCookieEmbedUri(url, webViewUrl)) {
return try {
WebResourceResponse("text/html", "UTF-8", getEmbedWithReferer(request))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getEmbedWithReferer() can return null, would that be the correct thing to send in the WebResourceResponse?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. When I made it nullable, I was thinking to return a null response (so we continue loading the original request), but that's not what I'm doing here. Thanks for catching it!

@marcosholgado marcosholgado left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CrisBarreiro
CrisBarreiro merged commit 8199755 into develop Aug 1, 2025
9 checks passed
@CrisBarreiro
CrisBarreiro deleted the feature/cris/duckplayer/add-referer-header branch August 1, 2025 09:06
joshliebe pushed a commit that referenced this pull request Aug 8, 2025
Task/Issue URL:
https://app.asana.com/1/137249556945/task/1210811808963690?focus=true

### Description
Set referer header to local assets directory in compliance with new TOS

### Steps to test this PR

_Feature 1_
- [ ] Set up Charles Proxy
    - [ ] Disable macOS proxy under Charles toolbar > Proxy
- [ ] Enable SSL proxying and include location `*:*` under Charles
toolbar > Proxy > SSL Proxying settings
- [ ] Check IP address under Charles toolbar > Help > Local IP
addresses. Check port under Charles toolbar > Proxy settings
- [ ] Set up proxy for WiFi connection on your phone by setting IP
address and port from previous step
- [ ] Open the app and load http://charlesproxy.com/getssl
- [ ] Download the certificate and install as CA certificate
- [ ] Load a video on Duck Player
- [ ] Using Charles proxy, check that requests to
`https://www.youtube-nocookie.com/embed/...` have `referer` header set
to `http://android.mobile.duckduckgo.com`

### UI changes
n/a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants